package com.bamboo.custom.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

import androidx.annotation.Nullable;

/**
 * 项目名称：CustomViewExercise
 *
 * @Author bamboolife
 * 邮箱：core_it@163.com
 * 创建时间：2021/9/12 6:27 下午
 * 描述：
 */
public class ViewTest extends View {
    private Paint mPaint;
    public ViewTest(Context context) {
        super(context);
        initView();
    }

    public ViewTest(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        initView();
    }

    public ViewTest(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView();
    }

    private void initView() {
        mPaint=new Paint(Paint.ANTI_ALIAS_FLAG);
        mPaint.setDither(true);
        mPaint.setStrokeWidth(3);
        mPaint.setStyle(Paint.Style.STROKE);
        mPaint.setColor(Color.RED);
    }


    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        canvas.save();
        canvas.translate(50,100);
        canvas.drawRect(0,0,400,400,mPaint);
        canvas.restore();
        canvas.drawRect(0,0,500,500,mPaint);

    }
}
